package cn.yuanqiao.archive.storeRoom.service.impl;

import cn.yuanqiao.archive.storeRoom.domain.FileLocation;
import cn.yuanqiao.archive.storeRoom.mapper.FileLocationMapper;
import cn.yuanqiao.archive.storeRoom.service.IFileLocationService;
import cn.yuanqiao.common.exception.ServiceException;
import cn.yuanqiao.common.utils.StringUtils;
import cn.yuanqiao.common.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

@Service
public class FileLocationServiceImpl implements IFileLocationService {

    @Autowired
    private FileLocationMapper fileLocationMapper;


    @Override
    public List<FileLocation> getList(Map map) {
        String code= SecurityUtils.getTenantCode().toUpperCase();
        if(StringUtils.isEmpty(code)){
            throw new ServiceException("TenantCode is null");
        }
         String type=map.get("type").toString();
         String keyword=map.get("keyword")==null?"":map.get("keyword").toString();
         List<FileLocation> list=new ArrayList<>();
         //件层
         if("0".equals(type)){
             list=fileLocationMapper.getDaList(code,keyword);
         }else if("1".equals(type)){
          //卷层
            list=fileLocationMapper.getFolderList(code,keyword);
         }

        return list;
    }
}
